<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateFreelancersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('freelancers', function (Blueprint $table) {
            $table->unsignedBigInteger('id')->primary()->comment('雪花ID');
            $table->string('name')->comment('姓名');
            $table->string('phone')->comment('手机号');
            $table->string('email')->comment('邮箱');
            $table->string('id_card', 18)->comment('身份证号');
            $table->string('bank_account')->nullable()->comment('银行卡号');
            $table->string('bank_name')->nullable()->comment('开户银行');
            $table->enum('gender', ['', 'male', 'female'])->default('')->comment('性别');
            $table->enum('education', ['', 'junior_high', 'high_school', 'college', 'bachelor', 'master', 'doctor'])->default('')->comment('学历');
            $table->integer('age')->nullable()->comment('年龄');
            $table->text('resume')->nullable()->comment('简历信息');
            $table->enum('status', ['active', 'inactive'])->default('active')->comment('状态');
            $table->enum('verification_status', ['pending', 'approved', 'rejected'])->default('pending')->comment('四要素认证状态');
            $table->timestamps();
            
            /* 组合唯一约束 (phone, email, id_card 在租户内唯一) */
            $table->unique('phone');
            $table->index('email');
            $table->index('id_card');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('freelancers');
    }
}
